package com.geek.javase.ch17.work.tcpwork.tcp07v2;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Desc TODO
 * @Author
 * @Date 2025/11/10
 */
public class ThreadPool {

    private ThreadPoolExecutor pool;

    public ThreadPool(int corePoolSize, int maxPoolSize, int workQueueSize){
        pool = new ThreadPoolExecutor(corePoolSize , maxPoolSize , 60L , TimeUnit.SECONDS , new LinkedBlockingQueue<Runnable>(workQueueSize) , new ThreadPoolExecutor.AbortPolicy());
    }

    public void execute(Runnable task){
        pool.submit(task);
    }

    public void close(){
        pool.shutdown();
    }

}
